package com.letoken.platform.app.service.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.letoken.platform.app.service.AppSettingsService;
import com.letoken.platform.pub.constant.RedisKeyConstant;
import com.letoken.platform.repo.app.redis.AppJsonStringRedis;
import com.letoken.platform.repo.app.res.settings.QueryAppNodeAddressListRes;
import com.letoken.platform.repo.repo.dao.AppChainNodeMapper;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author wyl
 * @date 2023/2/1 18:19
 * @Version 1.0
 */
@Service
public class AppSettingsServiceImpl implements AppSettingsService {

    @Autowired
    private AppChainNodeMapper appChainNodeMapper;

    /**
     * 默认加入缓存（记得另外写逻辑设置失效）
     * @param type
     * @return
     */
    @Cacheable(cacheNames = RedisKeyConstant.CHAIN_NODE_LIST, key = "'list_' + #type", sync = true)
    @Override
    public List<QueryAppNodeAddressListRes> chainNodeAddressList(Integer type) {
        return appChainNodeMapper.chainNodeAddressList(type);
    }
}
